import { check_type, plan_state, result } from '@/plugins/mate.js'

let state_dir = {
    1: '待处理',
    2: '已完成',
    3: '未完成',
}
let state_color = {
    1: '#7F8617',
    2: '#269846',
    3: '#E54032',
}
//是否停机
let shut = {
    1: '是',
    2: '否',
}
let shut_color = {
    1: '#E54032',
    2: '#289947',
}
let degree_dir = {
    1: '一般',
    2: '中等',
    3: '严重',
}
let degree_color = {
    1: '#FEFF00',
    2: '#db0b99',
    3: '#FE0000',
}
export const formConfig = [
    {
        name: 'scope_id_list',
        type: 'cascader',
        placeholder: '筛选范围',
        options: [],
    },
    {
        name: 'device_name',
        type: 'input',
        placeholder: '设备名称',
    },
    {
        name: 'reporter',
        type: 'input',
        placeholder: '报修人',
    },
    {
        name: 'sectioner',
        type: 'input',
        placeholder: '维修人',
    },
    {
        name: 'state',
        type: 'select_id',
        placeholder: '处理状态',
        options: [
            { id: 1, name: '待处理' },
            { id: 2, name: '已完成' },
            { id: 3, name: '未完成' },
        ],
    },
]

export const column = [
    {
        label: '设备名称',
        name: 'device_name',
    },
    {
        label: '报修人',
        name: 'reporter',
    },
    {
        label: '报修时间',
        name: 'create_time',
    },
    {
        label: '故障描述',
        name: 'type',
    },
    {
        label: '紧急程度',
        name: 'degree',
        format: (val) => degree_dir[val],
        color: (val) => degree_color[val],
    },
    {
        label: '是否停机',
        name: 'isShouDown',
        format: (val) => shut[val],
        color: (val) => shut_color[val],
    },
    {
        label: '维修人',
        name: 'sectioner',
    },
    {
        label: '处理状态',
        name: 'state',
        format: (val) => state_dir[val],
        color: (val) => state_color[val],
    },
    {
        label: '现场照片',
        name: 'photo',
        single: true,
    },
    {
        title: '操作',
        name: 'action',
        width: '260',
        buttons: [],
    },
]
// 添加保修单
export const config0 = [
    {
        name: 'device',
        type: 'device',
        placeholder: '请选择设备',
        label: '报修设备',
        required: true,
    },
    {
        name: 'reporter',
        type: 'input',
        placeholder: '报修人',
        label: '报修人',
        required: true,
    },
    {
        name: 'isShouDown',
        type: 'select',
        label: '是否停机',
        placeholder: '是否停机',
        required: true,
        options: [
            {
                value: 1,
                label: '是',
            },
            {
                value: 2,
                label: '否',
            },
        ],
    },
    {
        name: 'create_time',
        type: 'date',
        label: '报修时间',
        placeholder: '报修时间',
        required: true,
    },
    {
        name: 'type',
        type: 'input',
        placeholder: '故障描述',
        label: '故障描述',
        required: false,
    },
    {
        name: 'degree',
        type: 'select',
        placeholder: '紧急程度',
        options: [
            {
                value: 1,
                label: '一般',
            },
            {
                value: 2,
                label: '中等',
            },
            {
                value: 3,
                label: '严重',
            },
        ],
        label: '紧急程度',
        required: true,
    },
]

export const config1 = [
    {
        name: 'reporter',
        type: 'input',
        placeholder: '报修人',
        label: '报修人',
        required: true,
    },
    {
        name: 'isShouDown',
        type: 'select',
        label: '是否停机',
        placeholder: '是否停机',
        required: true,
        options: [
            {
                value: 1,
                label: '是',
            },
            {
                value: 2,
                label: '否',
            },
        ],
    },
    {
        name: 'create_time',
        type: 'date',
        label: '报修时间',
        placeholder: '报修时间',
        required: true,
    },
    {
        name: 'type',
        type: 'input',
        placeholder: '故障描述',
        label: '故障描述',
        required: false,
    },
    {
        name: 'section',
        type: 'input',
        label: '维修部门',
        required: true,
    },
    {
        name: 'sectioner',
        type: 'input',
        label: '维修人',
        required: true,
    },
    {
        name: 'out_name',
        label: '外协单位',
        type: 'input',
        required: false,
    },
    {
        name: 'photo',
        type: 'image',
        label: '现场照片',
    },
    {
        name: 'del_time',
        type: 'date',
        label: '维修时间',
        required: true,
    },
    {
        name: 'state',
        type: 'select',
        label: '维修状态',
        required: true,
        options: [
            {
                label: '已完成',
                value: 2,
            },
            {
                label: '未完成',
                value: 3,
            },
            {
                label: '待处理',
                value: 1,
            },
        ],
    },
    {
        name: 'result',
        type: 'input',
        label: '维修详情',
    },
]

//处理报修单
export const config2 = [
    {
        name: 'section',
        type: 'input',
        label: '维修部门',
        required: true,
    },
    {
        name: 'sectioner',
        type: 'input',
        label: '维修人',
        required: true,
    },
    {
        name: 'out_name',
        label: '外协单位',
        type: 'input',
        required: false,
    },
    {
        name: 'photo',
        type: 'image',
        label: '现场照片',
    },
    {
        name: 'del_time',
        type: 'date',
        label: '维修时间',
        required: true,
    },
    {
        name: 'state',
        type: 'select',
        label: '维修状态',
        required: true,
        options: [
            {
                label: '已完成',
                value: 2,
            },
            {
                label: '未完成',
                value: 3,
            },
            {
                label: '待处理',
                value: 1,
            },
        ],
    },
    {
        name: 'result',
        type: 'input',
        label: '维修详情',
    },
]
export const queryForm = {
    size: 20,
    page: 1,
    device_name: '',
    scope_id: null,
    cycle_id: null,
    type_id: null,
    scope_id_list: [],
    cycle_type: null,
    plan_state: null,
    content_id: null,
    id: null,
}
